package company.GuangLianDa;

import java.util.HashMap;
import java.util.Scanner;

/**
 * @ClassName P1
 * @Description
 * @Company inspur
 * @Author Kevin
 * @Date 2020/7/31 19:56
 * @Version 1.0
 */
public class P1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        HashMap<Integer, Integer> map = new HashMap<>();
        int len = 0, weight = 0;
        int res = -1;
        for (int i = 0; i < n; i++) {
            num[i] = sc.nextInt();

            if (!map.containsKey(num[i])) {
                map.put(num[i], 0);
            }
            map.put(num[i], map.get(num[i])+1);

            if (map.get(num[i]) == 2 && num[i] > 0) {
                if (num[i] > len) {
                    weight = len;
                    len = num[i];
                    res = len * weight;
                }
            } else if (map.get(num[i]) == 4) {
                if (num[i] > 0 && res < num[i] * num[i]) {
                    res = num[i] * num[i];
                }
            }
        }

        if (res <= 0) {
            System.out.println(-1);
        } else {
            System.out.println(res);
        }
    }
}
